<?php

use think\facade\Db;

// 应用公共文件
/**
 * @xk 字节转换
 *
 * @method bytesChanage
 *
 * @param int $byte [description]
 *
 * @return [type] [description]
 * @Author xkyinzhe                <zhonghuaxinxing@sina.cn>
 * @Time   2021-04-15T11:10:16+080
 */
function bytesChanage($byte = 200)
{
    $p = 0;
    $format = 'B';
    if ($byte > 0 && $byte < 1024) {
        $p = 0;

        return number_format($byte).' '.$format;
    }
    if ($byte >= 1024 && $byte < pow(1024, 2)) {
        $p = 1;
        $format = 'KB';
    }
    if ($byte >= pow(1024, 2) && $byte < pow(1024, 3)) {
        $p = 2;
        $format = 'MB';
    }
    if ($byte >= pow(1024, 3) && $byte < pow(1024, 4)) {
        $p = 3;
        $format = 'GB';
    }
    if ($byte >= pow(1024, 4) && $byte < pow(1024, 5)) {
        $p = 3;
        $format = 'TB';
    }
    $byte /= pow(1024, $p);

    return number_format($byte, 3).' '.$format;
}
function getNumberShow($num = 0)
{
    $num = intval($num);
    if ($num > 10000) {
        return round(($num/10000), 2).'万人';
    } elseif ($num > 1000 && $num < 10000) {
        return round(($num/1000), 2).'千人';
    } elseif ($num >= 0 && $num < 1000) {
        return $num.'人';
    }
}
/**
 * @xk 汉字转拼音
 *
 * @method getPinyin
 *
 * @param [type] $str         [description]
 * @param string $ret_format  [description]
 * @param string $placeholder [description]
 * @param string $allow_chars [description]
 *
 * @return [type] [description]
 * @Author xkyinzhe                <zhonghuaxinxing@sina.cn>
 * @Time   2021-04-19T14:09:43+080
 */
function getPinyin($str, $ret_format = 'all', $placeholder = '_', $allow_chars = '/[a-zA-Z\d ]/')
{
    static $pinyins = null;
    if (null === $pinyins) {
        $file_path = '../vendor/Chinese.txt';
        if (file_exists($file_path)) {
            $data = file_get_contents($file_path); //将整个文件内容读入到一个字符串中
        }
        $rows = explode('|', $data);
        $pinyins = [];
        foreach ($rows as $v) {
            list($py, $vals) = explode(':', $v);
            $chars = explode(',', $vals);
            foreach ($chars as $char) {
                $pinyins[$char] = $py;
            }
        }
    }
    $str = trim($str);
    $len = mb_strlen($str, 'UTF-8');
    $rs = '';
    for ($i = 0; $i < $len; ++$i) {
        $chr = mb_substr($str, $i, 1, 'UTF-8');
        $asc = ord($chr);
        if ($asc < 0x80) { // 0-127
            if (preg_match($allow_chars, $chr)) { // 用参数控制正则
                $rs .= $chr; // 0-9 a-z A-Z 空格
            } else { // 其他字符用填充符代替
                $rs .= $placeholder;
            }
        } else { // 128-255
            if (isset($pinyins[$chr])) {
                $rs .= 'first' === $ret_format ? $pinyins[$chr][0] : ($pinyins[$chr].' ');
            } else {
                $rs .= $placeholder;
            }
        }
        if ('one' === $ret_format && '' !== $rs) {
            return strtoupper($rs[0]);
        }
    }

    return preg_replace('# #', '', $rs); //去除所有空格输出
}
/**
 * @xk curl访问
 *
 * @method https_request
 *
 * @param [type] $url  [description]
 * @param [type] $data [description]
 *
 * @return [type] [description]
 * @Author xkyinzhe                <zhonghuaxinxing@sina.cn>
 * @Time   2021-04-19T17:28:31+080
 */
function https_request($url, $data = null, $headers = ["Content-type: application/json;charset='utf-8'"])
{
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    if (!empty($data)) {
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
    }
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($curl);
    curl_close($curl);

    return $output;
}
/**
 * @xk 清空数据表
 *
 * @method clearResetDb
 *
 * @param [type] $db [description]
 * @Author xkyinzhe                <zhonghuaxinxing@sina.cn>
 * @Time   2021-04-21T13:10:34+080
 */
function clearResetDb($db)
{
    $res = Db::execute('TRUNCATE TABLE '.config('database.connections.mysql.prefix').$db);

    return $res ? $res : '';
}
/**
 * @xk 生成密码
 *
 * @method makePass
 *
 * @param [type] $pass [description]
 * @param [type] $key  [description]
 *
 * @return [type] [description]
 * @Author xkyinzhe                <zhonghuaxinxing@sina.cn>
 * @Time   2021-04-21T18:00:13+080
 */
function makePass($pass, $key)
{
    $pass = md5($pass).$key;
    $password = md5(hash('sha256', $pass));

    return $password ? $password : '';
}
/**
 * @xk 拆解文本域为数组
 *
 * @method chanageStringToArray
 *
 * @param [type] $string [description]
 *
 * @return [type] [description]
 * @Author xkyinzhe                <zhonghuaxinxing@sina.cn>
 * @Time   2021-04-25T13:50:56+080
 */
function chanageStringToArray($string)
{
    $sku_values = trim($string);
    $sku_arrays = explode("\n", $sku_values); //拆分的数组中有空值元素，需要去除
    // dump($sku_arrays); die();
    foreach ($sku_arrays as $k => $v) {
        if (empty($v)) {
            unset($sku_arrays[$k]);
        }
    }

    return array_values($sku_arrays); //这一步是重新建立索引
}

/**
 * @xk 获取多个数组的笛卡尔积
 *
 * @method combineDika
 *
 * @return [type] [description]
 * @Author xkyinzhe                <zhonghuaxinxing@sina.cn>
 * @Time   2021-04-26T10:37:26+080
 */
function combineDika()
{
    $data = func_get_args();
    $data = current($data);
    $cnt = count($data);
    $result = [];
    $arr1 = array_shift($data);
    foreach ($arr1 as $key => $item) {
        $result[] = [$item];
    }

    foreach ($data as $key => $item) {
        $result = combineArray($result, $item);
    }

    return $result;
}
/**
 * @xk 获取两个数组的笛卡尔积
 *
 * @method combineArray
 *
 * @param [type] $arr1 [description]
 * @param [type] $arr2 [description]
 *
 * @return [type] [description]
 * @Author xkyinzhe                <zhonghuaxinxing@sina.cn>
 * @Time   2021-04-26T10:37:07+080
 */
function combineArray($arr1, $arr2)
{
    $result = [];
    foreach ($arr1 as $item1) {
        foreach ($arr2 as $item2) {
            $temp = $item1;
            $temp[] = $item2;
            $result[] = $temp;
        }
    }

    return $result;
}
/**
 * @xk 获取完整链接
 *
 * @method getShowUrl
 *
 * @param [type] $url [description]
 *
 * @return [type] [description]
 * @Author xkyinzhe                <zhonghuaxinxing@sina.cn>
 * @Time   2021-05-06T10:24:12+080
 */
function getShowUrl($url='', $type='')
{
    $upload_type = $type ? $type : config('system_config.upload_type');
    switch ($upload_type) {
      case '0':
        $web_url = 'https://'.$_SERVER['HTTP_HOST'];
        break;
      case '1':
        $web_url = config('oss.ShowUrl');
        break;
      case 'x':
        $web_url = 'https://'.$_SERVER['HTTP_HOST'];
        break;
      default:
        // code...
        break;
    }
    $url = str_replace("\/", '/', str_replace('"', '', $url));
    // 匹配http(s)的表达式
    $preg = "/^http(s)?:\\/\\/.+/";
    if (preg_match($preg, $url)) {
        return $url ? $url : '';
    } else {
        return $url ? $web_url.$url : '';
    }
}
/**
 * @xk 获取组图
 *
 * @method getPicArr
 * @param  [type]     $value                     [description]
 * @return [type]     [description]
 * @Time   2021-08-25
 * @City   青岛
 * @Author xkyinzhe   <zhonghuaxinxing@sina.cn>
 */
function getPicArr($value)
{
    $arr = explode(',', $value);
    if ($arr) {
        foreach ($arr as $key => $value) {
            $arr[$key] = getShowUrl(str_replace("\/", '/', str_replace('"', '', $value)));
        }
    }
    return $arr ? $arr : [];
}
/**
 * @xk 格式化时间输出
 *
 * @method chanageDateString
 *
 * @param [type] $data [description]
 * @param int    $type [description]
 *
 * @return [type] [description]
 * @Author xkyinzhe                <zhonghuaxinxing@sina.cn>
 * @Time   2021-05-06T15:48:12+080
 */
function chanageDateString($data, $type = 1)
{
    switch ($type) {
        case '1':
            $time = date('Y-m-d H:i', strtotime($data));
            break;
        case '2':
            $time = date('Y.m.d', strtotime($data));
            break;
        case '3':
            $time = date('m-d H:i', strtotime($data));
            break;
        case '4':
            $time = date('m.d', strtotime($data));
            break;
        case '5':
            $time = date('Y-m-d', strtotime($data));
            break;
        case '6':
            $time = date('Y.m.d h.i', strtotime($data));
            break;
        case '7':
            $time = date('m-d', strtotime($data));
            break;
        case '8':
            $time = date('H:i', strtotime($data));
            break;
        case '9':
            $time = date('H:i:s', strtotime($data));
            break;
        case '10':
            $time = date('Y/m/d', strtotime($data));
            break;
        default:
            $time = $data;
            break;
    }

    return $time;
}
/**
 * @xk 转化可以使用的详情
 *
 * @method chanageContent
 *
 * @param [type] $content [description]
 *
 * @return [type] [description]
 * @Author xkyinzhe                <zhonghuaxinxing@sina.cn>
 * @Time   2021-05-06T16:10:02+080
 */
function chanageContent($content)
{
    if ($content) {
        $upload_type = config('system_config.upload_type');
        switch ($upload_type) {
        case '0':
          $web_url = 'https://'.$_SERVER['HTTP_HOST'];
          break;
        case '1':
          $web_url = config('oss.ShowUrl');
          break;
        default:
          $web_url = 'https://'.$_SERVER['HTTP_HOST'];
          break;
      }
        // $pregRule = '/<[img|IMG].*?src="/';
        // $contenf = preg_replace($pregRule, '<img src="'.$web_url, $content);
        // $pregRulex = '/<[source|SOURCE].*?src="/';
        // $conten = preg_replace($pregRulex, '<source src="'.$web_url, $contenf);
        $contentx = str_replace('$nbsp;', ' ', $content);
        $contents = str_replace('style=""', ' ', $contentx);
        $content = str_replace('<img', "<img style='width:100%; height:auto;display: block;margin-top: 10px' ", $contents);
    }
    return $content;
}
/**
 * @xk 获取订单状态
 *
 * @method getStatusTxt
 *
 * @param [type] $status [description]
 *
 * @return [type] [description]
 * @Author xkyinzhe                <zhonghuaxinxing@sina.cn>
 * @Time   2021-05-11T16:58:41+080
 */
function getStatusTxt($status=0, $refund_status=0, $shipping_type=1)
{
    if ($refund_status == 2) {
        return '整单售后';
    } else {
        $statusarr = config('status_config.order_status');
        if ($shipping_type == 2 && $status == 2) {
            return '待自提';
        } else {
            return $statusarr[$status];
        }
    }
}
/**
 * @xk 获取订单状态颜色版
 *
 * @method getStatusTxt1
 * @param  integer       $status                    [description]
 * @param  integer       $refund_status             [description]
 * @param  integer       $shipping_type             [description]
 * @return [type]        [description]
 * @Time   2021-11-30
 * @City   青岛
 * @Author xkyinzhe      <zhonghuaxinxing@sina.cn>
 */
function getStatusTxt1($status=0, $refund_status=0, $shipping_type=1)
{
    if ($refund_status == 2) {
        return '<span style="color:red;">整单售后</span>';
    } else {
        $statusarr = [
          '0' => '<span style="color:black;">待付款</span>',
          '1' => '<span style="color:red;">待发货<span>',
          '2' => '<span style="color:green;">配送中<span>',
          '3' => '<span style="color:blue;">已完成<span>',
          '5' => '<span style="color:#ff5722;">订单关闭<span>',
          '6' => '<span style="color:#e91e63;">订单取消<span>'
        ];
        if ($shipping_type == 2 && $status == 2) {
            return '待自提';
        } else {
            return $statusarr[$status];
        }
    }
}
function getGoodsOrderStatus($status = 0.10)
{
    $statusarr = config('status_config.goods_order_status');
    return $statusarr[$status];
}

/**
 * @xk 写入日志
 *
 * @method createLog
 * @param  string     $path                      [description]
 * @param  string     $content                   [description]
 * @return [type]     [description]
 * @Time   2021-10-29
 * @City   青岛
 * @Author xkyinzhe   <zhonghuaxinxing@sina.cn>
 */
function createLog($path = 'up/', $content='')
{
    $log_path = app()->getRootPath().'/public/log/'.$path; //写入到运行目录中
    if (!file_exists($log_path)) {
        mkdir($log_path, 0766, true);
    }
    chown($log_path, 'www');
    chmod($log_path, 0766);

    $end_path = $log_path.date('Y-m-d').'.txt';
    $contents = '-------------------------'.date('Y-m-d H:i:s')."------------".microtime()."-----------------\n";
    $content = $contents.$content."\n";
    file_put_contents($end_path, $content, FILE_APPEND);
    // 常识解决 写入文件不同身份创建不同权限问题
    if (file_exists($end_path)) {
        chown($end_path, 'www');
        chmod($end_path, 0766);
    }
}

/**
 * web页面方法.
 *
 * @param $title
 * @param $content
 *
 * @return \think\response
 */
function web_page($title, $content)
{
    $data = <<<EOX
<!DOCTYPE html><html lang="en"><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<title>$title</title>
<style> img {vertical-align:middle; width:100%;} </style></head><body>
EOX;
    $data .= str_replace('class="tools"', 'class="tools" hidden', $content);
    $data .= <<<EOX
</body></html>
EOX;

    return \think\Response::create($data, 'html');
}
/**
 * @xk 获取真实ip
 *
 * @method getRealIP
 *
 * @return [type] [description]
 * @Author xkyinzhe                <zhonghuaxinxing@sina.cn>
 * @Time   2021-05-19T11:23:06+080
 */
function getRealIP()
{
    $forwarded = request()->header('x-forwarded-for');
    if ($forwarded) {
        $ip = explode(',', $forwarded)[0];
    } else {
        $ip = request()->ip();
    }

    return $ip;
}
/**
 * @xk 获取店铺审核状态
 *
 * @method getStoreChect
 * @param  boolean       $is_check                  [description]
 * @return [type]        [description]
 * @Time   2021-08-19
 * @City   青岛
 * @Author xkyinzhe      <zhonghuaxinxing@sina.cn>
 */
function getStoreChect($is_check)
{
    $storeCheck = config('store.storeCheck');
    return $storeCheck[$is_check];
}
/**
 * @xk 获取店铺状态
 *
 * @method getStoreStatus
 * @param  [type]         $status                    [description]
 * @return [type]         [description]
 * @Time   2021-08-19
 * @City   青岛
 * @Author xkyinzhe       <zhonghuaxinxing@sina.cn>
 */
function getStoreStatus($status)
{
    $storeStatus = config('store.storeStatus');
    return $storeStatus[$status];
}
/**
 * @xk 截取字符串
 *
 * @method msubstr
 * @param  [type]     $str                       [description]
 * @param  integer    $start                     [description]
 * @param  [type]     $length                    [description]
 * @param  string     $charset                   [description]
 * @param  boolean    $suffix                    [description]
 * @return [type]     [description]
 * @Time   2021-08-25
 * @City   青岛
 * @Author xkyinzhe   <zhonghuaxinxing@sina.cn>
 */
function msubstr($str='', $start = 0, $length=0, $charset = 'utf-8', $suffix = true)
{
    $str = strip_tags(htmlspecialchars_decode($str)); //去除html标签
    if (function_exists('mb_substr')) {
        if ($suffix) {
            if (strlen($str) > $length) {
                return mb_substr($str, $start, $length, $charset).'...';
            } else {
                return mb_substr($str, $start, $length, $charset);
            }
        } else {
            return mb_substr($str, $start, $length, $charset);
        }
    } elseif (function_exists('iconv_substr')) {
        if ($suffix) {
            return iconv_substr($str, $start, $length, $charset);
        } else {
            return iconv_substr($str, $start, $length, $charset);
        }
    }
}

/**
 * @xk 平台操作类型
 *
 * @method getFinanceAct
 * @param  [type]        $value                     [description]
 * @return [type]        [description]
 * @Time   2021-10-09
 * @City   青岛
 * @Author xkyinzhe      <zhonghuaxinxing@sina.cn>
 */
function getFinanceAct($value)
{
    switch ($value) {
    case '1':
      return '订单支付';
      break;
    case '2':
      return '订单支付';
      break;
    case '3':
      return '用户提现';
      break;
    case '4':
      return '用户退款';
      break;
    default:
      return '其他';
      break;
  }
}
/**
 * @xk 平台出入帐类型
 *
 * @method getFinanceEntry
 * @param  [type]          $value                     [description]
 * @return [type]          [description]
 * @Time   2021-10-09
 * @City   青岛
 * @Author xkyinzhe        <zhonghuaxinxing@sina.cn>
 */
function getFinanceEntry($value)
{
    switch ($value) {
    case '1':
      return '入账';
      break;
    case '2':
      return '出账';
      break;

    default:
      return  '其他';
      break;
  }
}

/**
 * @xk 一句话拆分成多句
 *
 * @method autoLineSplit
 * @param  [type]        $str                       [description]
 * @param  [type]        $fontFamily                [description]
 * @param  [type]        $fontSize                  [description]
 * @param  [type]        $charset                   [description]
 * @param  [type]        $width                     [description]
 * @return [type]        [description]
 * @Time   2021-10-20
 * @City   青岛
 * @Author xkyinzhe      <zhonghuaxinxing@sina.cn>
 */
function autoLineSplit($str, $fontFamily, $fontSize, $charset, $width)
{
    $_string = '';
    $__string = '';
    for ($i = 0; $i < mb_strlen($str, $charset); $i++) {
        // 查询已有字符串长度
        $box = imagettfbbox($fontSize, 0, $fontFamily, $_string);
        $_string_length = max($box[2], $box[4]) - min($box[0], $box[6]);
        // 查询接下来这个字符的宽度
        $nextString = mb_substr($str, $i, 1, $charset);
        $box = imagettfbbox($fontSize, 0, $fontFamily, $nextString);
        $nextStringLen = max($box[2], $box[4]) - min($box[0], $box[6]);
        if ($_string_length + $nextStringLen < $width) {
            $_string .= $nextString;
        } else {
            $__string .= $_string . "\n";
            $_string = $nextString;
        }
    }
    $__string .= $_string;
    return $__string;
}
/**
 * @xk 获取相对月份
 * @param  string  $show_type               [description]
 * @param  integer $type                    [description]
 * @return [type]             [description]
 */
 function getLastDate($show_type='Ym', $type=2, $month= 1)
 {
     $now_date = date('Ym'); // 当前月份

     $tmp_year = substr($now_date, 0, 4); // 截取前四位

     $tmp_mon = substr($now_date, 4, 2); // 截取后两位
     switch ($type) {
     case '1':
       return date($show_type); // 输出当月
       break;
     case '2':
      // return date($show_type); // 输出当月
       $tmp_forwardmonth =mktime(0, 0, 0, $tmp_mon-$month, 1, (int)$tmp_year);
       return date($show_type, $tmp_forwardmonth);
       break;
     case '3':
       $tmp_nextmonth = mktime(0, 0, 0, $tmp_mon+$month, 1, (int)$tmp_year);
       return date($show_type, $tmp_nextmonth);
       break;
     default:
       return date($show_type); // 输出当月
       break;
   }
 }
 /**
  * @xk 安全url加密
  *
  * @method  urlsafe_b64encode
  * @param   [type]            $string                    [description]
  * @return  [type]            [description]
  * @Version V5.0
  * @Time    2021-12-28
  * @City    青岛
  * @Author  xkyinzhe          <zhonghuaxinxing@sina.cn>
  */
 function urlsafe_b64encode($string)
 {
     $data = base64_encode($string);
     $data = str_replace(array('+','/','='), array('-','_',''), $data);
     return $data;
 }
 /**
  * @xk 实现oss图片文字拼接
  *
  * @method  ossprocessTitle
  * @param   [type]          $title                     [description]
  * @param   [type]          $startX                    [description]
  * @param   [type]          $startY                    [description]
  * @return  [type]          [description]
  * @Version V5.0
  * @Time    2021-12-28
  * @City    青岛
  * @Author  xkyinzhe        <zhonghuaxinxing@sina.cn>
  */
 function ossprocessTitle($title, $startX, $startY, $size=28, $color='000000', $postion = 'g_sw', $voffset='')
 {
     $style = '';
     $offsetY = 0;
     do {
         $subtitle = mb_substr($title, 0, 14);
         //输出文章标题
         $style .= '/watermark,text_'.urlsafe_b64encode($subtitle).','.$postion.',x_'.$startX.',y_'.($startY+$offsetY).',type_d3F5LXplbmhlaQ,color_'.$color.',size_'.$size;
         if ($voffset != '') {
             $style .= ',voffset_'.$voffset;
         }
         //获取剩下的文章标题
         $title = mb_substr($title, 15);
         $offsetY += 36;
     } while ($title);
     return $style;
 }
 /**
  * @xk 获取售后类型
  * @method                                 getRefundTypeTxt
  * @param                                  [type] $type  [description]
  * @return                                 [type] [description]
  * @Version：V5.0
  * @Author：xkyinzhe                        <zhonghuaxinxing@sina.cn>
  * @City：                                  青岛
  * @Time：2022-02-23Tfalse15:false10:00+080
  */
 function getRefundTypeTxt($type)
 {
     $array = config('status_config.refund_type');
     return $array[$type];
 }
 /**
  * @xk 售后状态转文字
  *
  * @method getRefundStatusText
  * @param  [type]              $status                    [description]
  * @return [type]              [description]
  * @Time   2021-11-02
  * @City   青岛
  * @Author xkyinzhe            <zhonghuaxinxing@sina.cn>
  */
 function getRefundStatusText($status)
 {
     $statusarr = config('status_config.refund_status');
     return $statusarr[$status];
 }
 /**
  * @xk 颜色版售后状态
  * @param  [type] $status               [description]
  * @return [type]         [description]
  */
 function getRefundStatusColorText($status)
 {
     $statusarr = $statusarr = config('status_config.refund_status_color');
     return $statusarr[$status];
 }

 /**
  * @xk 支付方式获取
  *
  * @method getPayTypeText
  * @param  [type]         $value                     [description]
  * @return [type]         [description]
  * @Time   2021-10-09
  * @City   青岛
  * @Author xkyinzhe       <zhonghuaxinxing@sina.cn>
  */
 function getPayTypeText($value)
 {
     $statusarr = $statusarr = config('status_config.pay_type');
     return $statusarr[$value];
 }
 /**
  * @xk 获取佣金类型
  * @method                                      getBonusType
  * @return                                      [type] [description]
  * @Version：V5.0
  * @Author：xkyinzhe                             <zhonghuaxinxing@sina.cn>
  * @City：                                       青岛
  * @Time：2022-02-24Tfalse13:false22:false56+080
  */
 function getBonusType($value)
 {
     $statusarr = $statusarr = config('status_config.bonus_type');
     return $statusarr[$value];
 }
 function replace_specialChar($strParam)
 {
     $regex = "/\/|\～|\，|\。|\！|\？|\“|\”|\【|\】|\『|\』|\：|\；|\《|\》|\’|\‘|\ |\·|\~|\!|\@|\#|\\$|\%|\^|\&|\*|\(|\)|\_|\+|\{|\}|\:|\<|\>|\?|\[|\]|\,|\.|\/|\;|\'|\`|\-|\=|\\\|\|/";
     return preg_replace($regex, "", $strParam);
 }
 function getTeamChilds($childs, $l_user_sn)
 {
     $Teams=array();//最终结果
   $l_user_sns=array($l_user_sn);//第一次执行时候的用户id
    do {
        $othermids=array();
        $state=false;
        foreach ($l_user_sns as $valueone) {
            foreach ($childs as $key => $valuetwo) {
                if ($valuetwo['l_user_sn']==$valueone) {
                    $Teams[]=$valuetwo['user_sn'];//找到我的下级立即添加到最终结果中
                    $othermids[]=$valuetwo['user_sn'];//将我的下级id保存起来用来下轮循环他的下级
                    unset($childs[$key]);
                    $state=true;
                }
            }
        }
        $l_user_sns=$othermids;//foreach中找到的我的下级集合,用来下次循环
    } while ($state==true);

     return $Teams;
 }
 /**
  * @xk 混合js转义
  * @method          encodeURIComponent
  * @param           [type] $str  [description]
  * @return          [type] [description]
  * @Version：V5.0
  * @Author：xkyinzhe <zhonghuaxinxing@sina.cn>
  * @City：           青岛
  * @Time：2022-05-25
  */
 function encodeURIComponent($str)
 {
     $revert = array('%21'=>"!",'%2A'=>"*",'%27'=>"",'%28'=>"(",'%29'=>')');
     return strtr(rawurlencode($str), $revert);
 }
 /**
  * @xk 检测当前是否 正常
  * @method          checkNowTime
  * @return          [type] [description]
  * @Version：V6.0
  * @Author：xkyinzhe <zhonghuaxinxing@sina.cn>
  * @City：青岛
  * @Time：2022-08-12
  */
 function checkNowTime(){
   $time = time();
   $start_time = strtotime(date('2022-08-13 20:30:01'));
   $end_time = strtotime(date('2022-08-14 05:00:00'));
   if($time >= $start_time && $end_time >= $time){
     return 0;
   }else{
     return 1;
   }
 }
